//
//  NSBundleAdditions.m
//  UITestingKit
//
//  Created by Ofri Wolfus on 03/02/07.
//  Copyright 2007 Ofri Wolfus. All rights reserved.
//

#import "NSBundleAdditions.h"
#import <objc/objc-class.h>
#import <objc/objc-runtime.h>


@implementation NSBundle (DPAdditions)

- (NSSet *)classes {
	CFMutableSetRef set = CFSetCreateMutable(kCFAllocatorDefault, 0, NULL);
	int i, count = objc_getClassList(NULL, 0);
	Class *classes = calloc(count, sizeof(Class));
	
	objc_getClassList(classes, count);
	
	for (i = 0; i < count; i++) {
		Class cls = classes[i];
		
		if ([[NSBundle bundleForClass:cls] isEqualTo:self])
			CFSetAddValue(set, cls);
	}
	
	free(classes);
	return [(NSSet *)set autorelease];
}

@end
